<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue-v2.6.11.js"></script>

</head>
<body>
    <div id="app">
        <button @click="testGet">GET请求</button>
        <button @click="testPost">POST请求</button>
    </div>
</body>

<script type="text/javascript">
    new Vue({
        el:"#app",
        data:{
            user:{
                id:1,
                username:"李四",
                sex:"女"
            }
        },
        methods:{
            testGet(){
                //axios.get().then(()=>{}).catch(()=>{});
                //get() 请求路径和请求参数
                //then() 成功后的回调
                //catch() 失败后的回调
                axios.get("/user/testGet1?id=1").then((response)=>{
                    console.log(response.data)
                }).catch((err)=>{
                    console.log(err)
                });
            },

            testPost(){
                axios.post("/user/testPost",this.user).then((response)=>{
                    console.log(response.data)
                }).catch((err)=>{
                    console.log(err)
                });
            }
        }
    });
</script>

</html>